package com.hechi.demo.controller;

import com.hechi.demo.dto.ResultResponse;
import com.hechi.demo.entity.Doctor;
import com.hechi.demo.exception.TijianException;
import com.hechi.demo.exception.TijianExceptionEnum;
import com.hechi.demo.service.OverallResultServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

@RestController
public class OverallResultController {
    @Autowired
    OverallResultServiceImpl overallResultService;

    @GetMapping("/overallResult/{orderId}")
    public ResultResponse getOverallResultList(HttpServletRequest request,@PathVariable("orderId") Integer orderId){
        //校验医生有没有登录
        Doctor doctor= (Doctor) request.getAttribute("doctor");
        if(doctor==null){
            throw new TijianException(TijianExceptionEnum.DOCTOR_LOGIN_TIMEOUT.getEnCode(),TijianExceptionEnum.DOCTOR_LOGIN_TIMEOUT.getEnMessage());
        }

        //调用service

        return overallResultService.getOverallResultList(orderId);


    }
}
